﻿using System;
using UnityEngine;

namespace Valve.VR.InteractionSystem
{
	// Token: 0x02000629 RID: 1577
	public class SpawnAndAttachAfterControllerIsTracking : MonoBehaviour
	{
		// Token: 0x060027DC RID: 10204 RVA: 0x000E80AC File Offset: 0x000E62AC
		private void Start()
		{
			this.hand = base.GetComponentInParent<Hand>();
		}

		// Token: 0x060027DD RID: 10205 RVA: 0x000E80BC File Offset: 0x000E62BC
		private void Update()
		{
			if (this.itemPrefab != null && this.hand.controller != null && this.hand.controller.hasTracking)
			{
				GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.itemPrefab);
				gameObject.SetActive(true);
				this.hand.AttachObject(gameObject, Hand.AttachmentFlags.SnapOnAttach | Hand.AttachmentFlags.DetachOthers | Hand.AttachmentFlags.DetachFromOtherHand | Hand.AttachmentFlags.ParentToHand, string.Empty);
				this.hand.controller.TriggerHapticPulse(800, EVRButtonId.k_EButton_Axis0);
				UnityEngine.Object.Destroy(base.gameObject);
				gameObject.transform.localScale = this.itemPrefab.transform.localScale;
			}
		}

		// Token: 0x040027E2 RID: 10210
		private Hand hand;

		// Token: 0x040027E3 RID: 10211
		public GameObject itemPrefab;
	}
}
